﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Net.Sockets;
using System.Configuration;
using System.Net;

namespace Bombif.Game
{
    public partial class GameMain
    {
        private void StartLobby()
        {
            //Add the host as the first player.
            string username = ConfigurationManager.AppSettings["username"];
            String ip = GetLocalIPAddress();
            Player player = new Player(1, username, ip);
            listePlayers.Add(player);

            //Start the Communication Socket
            startSend_Socket(send_socket);
            startReceive_Socket(receive_socket);
        }
   

        private void DrawLobbyScreen()
        {
            Texture2D pixel = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            pixel.SetData(new[] { Color.White });
            int width = GraphicsDevice.Viewport.Width;
            int height = GraphicsDevice.Viewport.Height;


            Vector2 vecteurParametre = new Vector2(width / 2,
                height / 2);

            Rectangle rectangleParam = new Rectangle(4, 4, (3 * width / 4) - 10, (3 * height / 4) - 10);

            Rectangle rectangleChat = new Rectangle(4, 3* height /4 +5, (3 * width / 4) - 10, (height / 4) - 10);

            Rectangle rectangleLaunch = new Rectangle(3 * width / 4 + 5, 3 * height / 4 + 5, ( width / 4) - 10, (height / 4) - 10);

            Rectangle rectangleStatus = new Rectangle(3 * width / 4 + 5, 4, ( width / 4) - 10, (3 * height / 4) - 10);

            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin();

            spriteBatch.Draw(BackGroundTitle, Vector2.Zero, Color.White);

            spriteBatch.Draw(pixel, rectangleParam, Color.DarkGreen);
            spriteBatch.Draw(pixel, rectangleChat, Color.Honeydew);
            spriteBatch.Draw(pixel, rectangleLaunch, Color.Ivory);
            spriteBatch.Draw(pixel, rectangleStatus, Color.SeaShell);

            //Test
            Color colorText = Color.White;
            DrawCenter(listePlayers[0].Ip, 50f, colorText);
            DrawCenter(listePlayers[0].Username, 250f, colorText);
            DrawCenter(listePlayers[0].NumPlayer.ToString(), 150f, colorText);



            spriteBatch.End();



        }
    }
}
